# -*- coding: UTF-8 -*-
import json

import requests


def fetch_api_data():
    """
    # 执行API调用并返回响应数据
    :return: api_data dict
    """

    owner = "kkxue"
    repo = "python_office_automation"
    data_type = "subscribers"
    url = "https://gitee.com/api/v5/repos/{owner}/{repo}/{data_type}".format(
        owner=owner,
        repo=repo,
        data_type=data_type
    )
    r = requests.get(url)
    print("Status code:", r.status_code)

    # 将API响应储存
    response_dict = r.json()

    # 打印结果
    print(json.dumps(response_dict, indent=4))

    return response_dict


def generate_pics(api_data):
    """根据返回的数据，生成图表"""
    pass


if __name__ == "__main__":
    api_data = fetch_api_data()
    generate_pics(api_data)
